package config

import "sync"

// Config 定义配置结构体（根据实际YAML结构调整）
type Config struct {
	Server struct {
		Port int `yaml:"port"`
	} `yaml:"server"`
	Database struct {
		DSN string `yaml:"dsn"`
	} `yaml:"database"`
	Cloud struct {
		AppId         string `yaml:"app_id"`
		PrivateBucket string `yaml:"private_bucket"`
		PublicBucket  string `yaml:"public_bucket"`
		Region        string `yaml:"region"`
		SecretId      string `yaml:"secret_id"`
		SecretKey     string `yaml:"secret_key"`
		BaseUrl       string `yaml:"base_url"`
	} `yaml:"cloud"`
	//扩展字段
	ExtendFields map[string]string `yaml:"extend_fields"`
}

var (
	conf *Config
	once sync.Once
)

func (c *Config) GetExtendFields(key string) string {
	return c.ExtendFields[key]
}

func GetGlobalConfig() *Config {
	once.Do(func() {
		Init()
	})
	return conf
}
